package com.dzu.medium;

/**
 * @author ZhaoDong
 * @date 2022/10/20 10:02
 * @description 553. 最优除法
 */
public class Test553 {
    public static void main(String[] args) {
        System.out.println(optimalDivision(new int[]{1000, 100, 100, 2}));
    }

    public static String optimalDivision(int[] nums) {

        int n = nums.length;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(nums[i]);
            if (i + 1 < n) {
                sb.append("/");
            }
        }
        if (n > 2) {
            sb.insert(sb.indexOf("/") + 1, "(");
            sb.append(")");
        }
        return sb.toString();

    }
}
